package practice;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.regex.Pattern;

public class ITEM2 {

  static    HashMap<Date,String> track = new HashMap<>();
    public static void main(String[] args) throws ParseException {



        String input= "1 2022 3 31 ranko";
        if(input.charAt(0)=='1')
        {

            add(input);
        }
    }
    public  static void add(String input) throws ParseException {
        String[] s = input.split(" ");
        StringBuffer sb = new StringBuffer();
        for (int i = 1; i <= 3; i++) {
           sb.append(s[i]+'/');
        }
        String s1 = sb.substring(0,sb.length()-1).toString();
        String pattern ="^\\d{4}\\-\\d{2}\\-\\d{2}$";
        boolean flag1 = Pattern.matches(pattern,s1);
        if(flag1==false)
            System.out.println("ERROR");
        else {
            Date parse = null;
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
            try {
                parse = sdf.parse(s1);
            } catch (ParseException e) {
                System.out.println("Error");
                e.printStackTrace();
            }


            String flag = s[s.length - 1];
            track.put(parse, flag);
        }

    }
}
